package me.zhengjie.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * 项目数据源配置
 */
@Configuration
public class SpringDataSourceConfig {

    @Bean(name = "eladminDataSource")
    @Qualifier("eladminDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.eladmin")
    @Primary
    public DataSource eladminDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "lvsmartDataSource")
    @Qualifier("lvsmartDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.lvsmart")
    public DataSource lvsmartDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "transDataSource")
    @Qualifier("transDataSource")
    @ConfigurationProperties(prefix = "spring.datasource.trans")
    public DataSource transDataSource() {
        return DataSourceBuilder.create().build();
    }
}
